package com.github.linmt.dbdoc4j.metadata.model.standard;

import java.util.ArrayList;
import java.util.List;

/**
 * User: Linmt
 * Date: 2022/12/2
 * Time: 13:39
 * Description: 表
 */
public class TableModel {
    private String tableName; // 表名
    private String tableType; // 表类型
    private String remark; // 字段
    private List<ColumnModel> columnList = new ArrayList<>();

    public static Builder builder() {
        return new Builder();
    }

    public static class Builder {
        private TableModel tableModel;

        public Builder() {
            this.tableModel = new TableModel();
        }

        public TableModel build() {
            return this.tableModel;
        }

        public Builder addColumn(ColumnModel columnModel) {
            this.tableModel.getColumnList().add(columnModel);
            return this;
        }

        public Builder addAllColumn(List<ColumnModel> columnModelList) {
            this.tableModel.getColumnList().addAll(columnModelList);
            return this;
        }

        public Builder tableName(String tableName) {
            this.tableModel.setTableName(tableName);
            return this;
        }

        public Builder remark(String remark) {
            this.tableModel.setRemark(remark);
            return this;
        }

        public Builder tableType(String tableType) {
            if ("BASE TABLE".equals(tableType)) {
                this.tableModel.setTableType(tableType);
            } else if ("VIEW".equals(tableType)) {
                this.tableModel.setTableType("");
            }
            return this;
        }
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public List<ColumnModel> getColumnList() {
        return columnList;
    }

    public String getTableType() {
        return tableType;
    }

    public void setTableType(String tableType) {
        this.tableType = tableType;
    }

    public void setColumnList(List<ColumnModel> columnList) {
        this.columnList = columnList;
    }
}
